﻿using Autofac;
using Autofac.Core;
using AutoFacLearn.Demo;
using AutoFacLearn.Demo.Interface;
using Microsoft.Extensions.DependencyModel;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.Loader;


namespace AutoFacLearn.注册Demo
{
    public class 最基本的注册
    {
        private static IContainer Container { get; set; }
        public void Demo(params Parameter[] parameters)
        {
            var builder = new ContainerBuilder();

            builder.RegisterType<User>().As<IUser>();

            //var output = new User();
            //builder.RegisterInstance(output).As<IUser>();

            //builder.Register(c => new User()).As<IUser>();
            Container = builder.Build();

            using (var scope = Container.BeginLifetimeScope())
            {
                var component = scope.Resolve<IUser>();
                component.Demo();
            }
        }
    }
}
